package com.usian.config;

/**
 * @author chen
 * @date 2021/1/27 - 22:07 - 星期三
 * @project usian_parent
 * @package com.usian.config
 * @by GGbomd猪猪侠
 */

import com.usian.interceptor.UserLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *拦截器·配置类
 */
@Component
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private UserLoginInterceptor userLoginInterceptor;

    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 看用户是否已经登录
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(userLoginInterceptor);
        // 没有登录拦截的具体的URL
        interceptorRegistration.addPathPatterns("/frontend/order/**");
    }
}
